//
//  Moya+Rx.swift
//  WanAndroidLearn
//
//  Created by TRS-Mobile on 2023/11/1.
//

import Moya
import RxSwift

extension PrimitiveSequence where Trait == SingleTrait, Element == Moya.Response {
    func map<T: ModelType>(_ type: T.Type) -> PrimitiveSequence<Trait, T> {
        return self.map(T.self, using: T.decoder)
            .do { error in
                if case let MoyaError.objectMapping(decodingError, _) = error as! MoyaError {
                    log.error(decodingError)
                }
            }
    }
}
